<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
    <style>
        .layui-form-item .input_area {
            width: 60px;
        }
        .layui-form-item .layui-middel-area {
            width: 400px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">
                    <div class="layui-form" wid200="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">发言频率：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">每</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="speak_rate" value="{$chat_ploy.speak_rate}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">秒最多发言一次</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_speak_rate" value="{$chat_ploy.toggle_speak_rate}">
                                <input type="checkbox" name="toggle_speak_rate" value="{$chat_ploy.toggle_speak_rate}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_speak_rate==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">单条消息连续数字长度：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">每条消息最多出现连续</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="single_msg_num_length" value="{$chat_ploy.single_msg_num_length}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">个连续数字</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_single_msg" value="{$chat_ploy.toggle_single_msg}">
                                <input type="checkbox" name="toggle_single_msg" value="{$chat_ploy.toggle_single_msg}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_single_msg==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">连续数字消息条数：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">最多允许连续</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="num_msg_count" value="{$chat_ploy.num_msg_count}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">条纯数字消息</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_num_msg_count" value="{$chat_ploy.toggle_num_msg_count}">
                                <input type="checkbox" name="toggle_num_msg_count" value="{$chat_ploy.toggle_num_msg_count}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_num_msg_count==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">链接限制：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">聊天室禁止发送链接</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_link_set" value="{$chat_ploy.toggle_link_set}">
                                <input type="checkbox" name="toggle_link_set" value="{$chat_ploy.toggle_link_set}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_link_set==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">连续触发风控：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">连续触发风控</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="continue_trigger_num" value="{$chat_ploy.continue_trigger_num}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">次，自动禁言</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="continue_trigger_banned" value="{$chat_ploy.continue_trigger_banned}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">小时</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_continue_trigger" value="{$chat_ploy.toggle_continue_trigger}">
                                <input type="checkbox" name="toggle_continue_trigger" value="{$chat_ploy.toggle_continue_trigger}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_continue_trigger==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">累计触发风控：</label>
                            <div class="layui-input-inline layui-middel-area">
                                <div class="layui-form-mid layui-word-aux">累计触发风控</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="total_trigger" value="{$chat_ploy.total_trigger}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">次，自动禁言</div>
                                <div class="layui-input-inline input_area">
                                    <input type="text" name="total_trigger_banned" value="{$chat_ploy.total_trigger_banned}" class="layui-input" placeholder="" lay-verify="required|intnum"/>
                                </div>
                                <div class="layui-form-mid layui-word-aux">小时</div>
                            </div>
                            <div class="layui-input-inline">
                                <input type="hidden" name="toggle_total_trigger" value="{$chat_ploy.toggle_total_trigger}">
                                <input type="checkbox" name="toggle_total_trigger" value="{$chat_ploy.toggle_total_trigger}" lay-filter="switchTest" lay-skin="switch" lay-text="开启|关闭" {$chat_ploy.toggle_total_trigger==1?'checked':''}>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="chatploySave">确认保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="/assets/cos-js-sdk-v5/cos-js-sdk-v5.js"></script>
<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: "/layuiadmin/"
        , version: "{:config('other.ui_version')}"
        , version: "{:config('other.ui_version')}"
    }).extend({
        index: "lib/index", //主入口模块
    }).use(['index', 'form', 'admin'], function () {
        var $ = layui.$
            , form = layui.form
            , admin = layui.admin;

        //自定义验证规则
        form.verify({
            intnum: function (value) {
                if (!(/(^\d*$)/.test(value))) {
                    return '必须为正整数数字';
                }
                if (value < 1) {
                    return '必须为正整数数字';
                }
            }
        });

        //监听指定开关
        // form.on('switch(switchTest)', function (data) {
        //     this.value = this.checked ? '1' : '0';
        // });

        form.on('switch(switchTest)', function (data) {
            var name = this.name;
            $("input[name=" + name + "]").val(this.checked ? '1' : '0');
        });

        form.on('submit(chatploySave)', function (obj) {
            console.log(obj);
            //提交
            layer.load();
            admin.req({
                url: "{:url('chatploy/edit_post')}"
                , data: obj.field
                , success: function (res) {
                    layer.closeAll('loading');
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 1});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1200);
                    }
                }
                , complete: function () {
                    layer.closeAll("loading");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
